<#assign contextPath=springMacroRequestContext.getContextPath() />
<#import "/public/frame/main.html" as frame />
<@frame.head "南航明珠商城-用户列表">
</@frame.head>
<body>
<nav class="breadcrumb"><i class="Hui-iconfont">&#xe67f;</i> 后台管理中心 <span class="c-gray en">&gt;</span> 系统管理 <span class="c-gray en">&gt;</span> 调查问卷管理  <span class="c-gray en">&gt;</span> 查看统计<a class="btn btn-success radius r" style="line-height:1.6em;margin-top:3px" href="javascript:location.replace(location.href);" title="刷新" ><i class="Hui-iconfont">&#xe68f;</i></a></nav>
<div class="page-container">
    <table class="table table-border table-bordered table-bg">
    </table>
    <div id="div_page" style="padding-top: 10px;float: right"></div>
</div>
<table class="form_table" width="100%">
	<tr align="left">

		<td>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;问卷名称：<span>${questionnaire.name}</span><br />
		</td>
		<br />
		<td>问卷有效期：
		${(questionnaire.startDate?string("yyyy-MM-dd"))!}&nbsp;&nbsp;
		${(questionnaire.endDate?string("yyyy-MM-dd"))!}</td>
		<td>参与人数：<span>${count}</span>
		</td>

	</tr>

</table>
<table class="order_table">
	<div id="test"></div>
</table>
							    <div>
							  
							   <#list questionList as question> 
                                                   <#if question.type==3>
                                                  
                                                <tr>  
                                                      <td>
                                                      <strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp; ${question.name}</strong>
													  </td>
											    </tr>
											  
                                       <table class="question_table" border="1" id="answer${question_index}" questionId="${question.id}">
											 <input type="hidden" name="page" value="0" id="page"/>
											   <tr>
											     <td>
											       <strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;答案</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
											       &nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;
											       <input type="button" class="btn btn-primary radius" id="detail" onclick="detailClick(this);" questionId="${question.id}" value="查看详情" />
											     </td>
											   
											   </tr>
													
													<#list textList as textMap>
													
													   <#list textMap?keys as testKey>
										                     <#if testKey=question.name>
												               <tr>
												                <td  height="60" width="400" >
																${textMap[testKey]}
															    </td>
															   </tr>
										                     </#if> 
														</#list> 
													</#list>
                                       <tr alig="right">
                                       <td align="right">
                                       <div class="wp-pagenavi">
                                      
							       	  </div>
							       	  </td>
							       	  </tr>
							       	  </table>
											 
												</#if> 
											</#list>
											
						</div>
					</body>
<@frame.end "default">
</@frame.end>
</html>
<script type="text/javascript" src="${contextPath}/resources/lib/My97DatePicker/4.8/WdatePicker.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/laypage/laypage.js"></script>
<script type="text/javascript" src="${contextPath}/resources/js/brand/query_brand.js"></script>
<script type="text/javascript"
	src="${contextPath}/resources/js/charts/FusionCharts.js"></script>
<script type="text/javascript"
	src="${contextPath}/resources/js/charts/statistic.js"></script>
	
<script type="text/javascript">
var path="${contextPath}";
        window.onload=function(){
           
           var list='${list}';
           var mapArray = eval(list);
           var index = 0;
           var questionId = "";
           for(var i=0;i<mapArray.length;i++){
            	for (var p in mapArray[i]) {
            		name = p.split("/")[0];
            		questionId=p.split("/")[1];
            	    var testData = new Array();
            	    for(var key in mapArray[i][p]){
						var map = {};
						map["key"] = key;
						map["value"] = mapArray[i][p][key];
						testData.push(map);
						
            	    }
            	}
            	   
            		
            	    var testId="test" + index;
            	    $("#test").after("<div class='question' questionId='"+questionId + "'id='test" + index + "'></div>" );
            	    index = index + 1;
                    var swfPath="static/js/charts/Pie2D.swf";
                    statistic(testId,testData,name,swfPath);
            }
          
        };
        
        $(".question").on("click",function(){
            var questionId = $(this).attr("questionId");
            var questionnaireId='${questionnaireId}';
            Hui_admin_tab(path + "/answer/answer_query_memberList?questionId="+questionId+"&questionnaireId="+questionnaireId); 
        });
       
        function detailClick(val){
            var questionId =$(val).attr("questionId");  
            var questionnaireId='${questionnaireId}';
            creatIframe(path + "/answer/answer_query_memberList?questionId="+questionId+"&questionnaireId="+questionnaireId,"问题答案详情"); 
        }; 
        
		function ajaxAct(pageIndex,page){
		        var url = path + "/answer/answer_queryText";
		        var questionId =$("#answer"+pageIndex).attr("questionId");  
				$.ajax({
					url : url,
					type : "post",
					dataType : "json",
					data : {
						"questionId" : questionId,
						"page" : page
					},
					success : function(msg) {
					   var result=eval(msg);
					   for (var p in result) {
					    if(p=="list"){
					     alist=result[p];
					    }else {
					      blist=result[p];
					    }
					   }
					    var html="<input type='hidden' name='page' value='"+page+"' id='page'/>"
									+"<tr><td><strong>答案</strong>&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
									+"&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;"
									+"<input type='button' id='detail' questionId='"+questionId+"' value='查看详情' />";
									
					  for (var i = 0; i < alist.length; i++) {
					               var a="<tr ><td  height='40' width='400' >"
									+alist[i]+"</td> </tr>";
								html+=a;
					     } 
					   var b="<tr alig='right'>"
                                    +"<td align='right'>"
                                     + "<div class='wp-pagenavi'>"+blist+"</div> </td> </tr>"; 
                                     html+=b; 
                        
					   $("#answer"+pageIndex).html(html);
					   
					}
					});
			
		}
          $(function(){
         
         	$("body").on("click",".wp-pagenavi a",function(){
         		var cur=$(this).parent().find(".current").text();
         		cur=+$.trim(cur);
         		var className=$(this).attr("class");
         		var page=1;
         		 if(className == 'nextpostslink'){
         		 	if($(this).text() == '上一页'){
         		 		page=cur-1;
         		 	}else{
         		 		page=cur+1;
         		 	}
         		    
         		}else{
         			page=+$(this).text();
         		}
         		var questionnaireId='${questionnaireId}';
            	//var questionId =$("#detail").attr("questionId"); 
               	document.getElementById("page").value=page;
               	var pageIndex=$(this).parents(".question_table").attr("id").replace("answer","");
               	pageIndex=+$.trim(pageIndex);
               	ajaxAct(pageIndex,page);
            	
         	});
         }); 
    </script>